package thread;

/**
 * 第二种创建线程的方式：
 * 实现Runnable接口，单独定义线程任务
 */
public class ThreadDemo2 {
    public static void main(String[] args) {
        //1.接口需要实例化(接口都需要被实例化）
        Runnable1 r1 = new Runnable1();
        Runnable2 r2 = new Runnable2();
        //2.实例化线程:
        Thread t1 = new Thread(r1);
        Thread t2 = new Thread(r2);

        t1.start();
        t2.start();
    }
}
class Runnable1 implements Runnable{
    public void run(){
        for (int i = 0; i < 1000; i++) {
            System.out.println("你是谁啊");
        }
    }
}

class Runnable2 implements Runnable{
    public void run(){
        for (int i = 0; i < 1000; i++) {
            System.out.println("我是查水表的");
        }
    }
}
